package com.xsr.pojo;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.math.BigDecimal;

/**
 * @author 邢式瑞
 * @version 1.0
 * @project gp14Sm
 * @date 2022/9/9 22:18
 */
public class MySerialize  extends JsonSerializer<Double> {



    @Override
    public void serialize(Double aDouble, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String s = BigDecimal.valueOf(aDouble).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
        jsonGenerator.writeString(s);
    }
}
